<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="姓名\手机号：">
          <el-input v-model="listPram.keyword" placeholder="请输入姓名\手机号" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click.native="getList">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="listData.list" :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}"
                border size="mini">
        <el-table-column coverImg="120" label="ID" prop="id"></el-table-column>
        <el-table-column label="用户名称" min-width="130" prop="userName"/>
        <el-table-column label="用户电话" min-width="80" prop="phone"/>
        <el-table-column label="创建时间" min-width="80" prop="createTime"/>
        <el-table-column align="center" fixed="right" label="操作" min-width="180">
          <template slot-scope="scope">
            <el-button v-has-permi="['admin:merchantActivities:delete']" icon="el-icon-delete" size="mini" type="danger"
                       @click="handlerDelete(scope.row.id)">删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[20,40,60,80,100]"
          :total="listData.count"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>

<script>
import {deleteApplication, gatApplicationList} from "@/api/entrepreneurs";
import {checkPermi} from "@/utils/permission";
export default {
  components: {},
  props: {
    id: {
      default: null
    }
  },
  data() {
    return {
      listData: { list: [],count:0 },
      listPram: {
        page: 0,
        limit: 20,
        id:'',
        keyword:''
      },
      tableLoading:false,
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    checkPermi,
    getList(){
      this.tableLoading=true
      this.listPram.id = this.id
      gatApplicationList(this.listPram).then(res=>{
        this.listData=res;
      }).finally(()=>{})
      this.tableLoading=false;
    },
    handlerDelete(id) {
      this.$confirm('确认删除该数据吗？').then(() => {
        const loading=this.$loading({text:'删除中',background:'rgba(255,255,255,.5)'})
        deleteApplication(id).then(() => {
          this.$message.success('删除成功')
          this.getList()
        }).finally(()=>{
          loading.close()
        })
      })
    },
    hideEditDialog() {
      this.editDialog.show = false
      this.getList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
    resetQuery(){
      this.listPram.keyword = '';
      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">

</style>

<style scoped>

</style>
